// This is a generated file

CAMLprim value
ml_cpSpaceDestroy( value space )
{
    cpSpaceDestroy( (cpSpace *) space );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceFree( value space )
{
    cpSpaceFree( (cpSpace *) space );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceFreeChildren( value space )
{
    cpSpaceFreeChildren( (cpSpace *) space );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceAddShape( value space, value shape )
{
    cpSpaceAddShape( (cpSpace *) space, (cpShape *) shape );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceAddStaticShape( value space, value shape )
{
    cpSpaceAddStaticShape( (cpSpace *) space, (cpShape *) shape );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceAddBody( value space, value body )
{
    cpSpaceAddBody( (cpSpace *) space, (cpBody *) body );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceAddConstraint( value space, value constr )
{
    cpSpaceAddConstraint( (cpSpace *) space, (cpConstraint *) constr );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceRemoveShape( value space, value shape )
{
    cpSpaceRemoveShape( (cpSpace *) space, (cpShape *) shape );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceRemoveStaticShape( value space, value shape )
{
    cpSpaceRemoveStaticShape( (cpSpace *) space, (cpShape *) shape );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceRemoveBody( value space, value body )
{
    cpSpaceRemoveBody( (cpSpace *) space, (cpBody *) body );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceRemoveConstraint( value space, value constr )
{
    cpSpaceRemoveConstraint( (cpSpace *) space, (cpConstraint *) constr );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceResizeStaticHash( value space, value dim, value count )
{
    cpSpaceResizeStaticHash( (cpSpace *) space, Double_val(dim), Int_val(count) );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceResizeActiveHash( value space, value dim, value count )
{
    cpSpaceResizeActiveHash( (cpSpace *) space, Double_val(dim), Int_val(count) );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceRehashStatic( value space )
{
    cpSpaceRehashStatic( (cpSpace *) space );
    return Val_unit;
}


CAMLprim value
ml_cpSpaceStep( value space, value dt )
{
    cpSpaceStep( (cpSpace *) space, Double_val(dt) );
    return Val_unit;
}


CAMLprim value
ml_cpBodyFree( value body )
{
    cpBodyFree( (cpBody *) body );
    return Val_unit;
}


CAMLprim value
ml_cpBodySlew( value body, value ml_pos, value dt )
{
    cpVect pos;
    pos.x = Double_field(ml_pos,0);
    pos.y = Double_field(ml_pos,1);

    cpBodySlew( (cpBody *) body, pos, Double_val(dt) );
    return Val_unit;
}


CAMLprim value
ml_cpBodyUpdateVelocity( value body, value ml_gravity, value damping, value dt )
{
    cpVect gravity;
    gravity.x = Double_field(ml_gravity,0);
    gravity.y = Double_field(ml_gravity,1);

    cpBodyUpdateVelocity( (cpBody *) body, gravity, Double_val(damping), Double_val(dt) );
    return Val_unit;
}


CAMLprim value
ml_cpBodyUpdatePosition( value body, value dt )
{
    cpBodyUpdatePosition( (cpBody *) body, Double_val(dt) );
    return Val_unit;
}


CAMLprim value
ml_cpBodyLocal2World( value body, value ml_v )
{
    CAMLparam0();
    CAMLlocal1( ml_ret );

    cpVect v;
    v.x = Double_field(ml_v,0);
    v.y = Double_field(ml_v,1);

    cpVect _ret = cpBodyLocal2World( (cpBody *) body, v );
    
    ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);

    Store_double_field( ml_ret, 0, _ret.x );
    Store_double_field( ml_ret, 1, _ret.y );

    CAMLreturn( ml_ret );
}


CAMLprim value
ml_cpBodyWorld2Local( value body, value ml_v )
{
    CAMLparam0();
    CAMLlocal1( ml_ret );

    cpVect v;
    v.x = Double_field(ml_v,0);
    v.y = Double_field(ml_v,1);

    cpVect _ret = cpBodyWorld2Local( (cpBody *) body, v );
    
    ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);

    Store_double_field( ml_ret, 0, _ret.x );
    Store_double_field( ml_ret, 1, _ret.y );

    CAMLreturn( ml_ret );
}


CAMLprim value
ml_cpBodyApplyImpulse( value body, value ml_j, value ml_r )
{
    cpVect j;
    j.x = Double_field(ml_j,0);
    j.y = Double_field(ml_j,1);

    cpVect r;
    r.x = Double_field(ml_r,0);
    r.y = Double_field(ml_r,1);

    cpBodyApplyImpulse( (cpBody *) body, j, r );
    return Val_unit;
}


CAMLprim value
ml_cpBodyResetForces( value body )
{
    cpBodyResetForces( (cpBody *) body );
    return Val_unit;
}


CAMLprim value
ml_cpBodyApplyForce( value body, value ml_f, value ml_r )
{
    cpVect f;
    f.x = Double_field(ml_f,0);
    f.y = Double_field(ml_f,1);

    cpVect r;
    r.x = Double_field(ml_r,0);
    r.y = Double_field(ml_r,1);

    cpBodyApplyForce( (cpBody *) body, f, r );
    return Val_unit;
}


CAMLprim value
ml_cpShapeFree( value shape )
{
    cpShapeFree( (cpShape *) shape );
    return Val_unit;
}


CAMLprim value
ml_cpResetShapeIdCounter( value unit )
{
    cpResetShapeIdCounter(  );
    return Val_unit;
}


CAMLprim value
ml_cpPinJointNew( value a, value b, value ml_anchr1, value ml_anchr2 )
{
    cpVect anchr1;
    anchr1.x = Double_field(ml_anchr1,0);
    anchr1.y = Double_field(ml_anchr1,1);

    cpVect anchr2;
    anchr2.x = Double_field(ml_anchr2,0);
    anchr2.y = Double_field(ml_anchr2,1);

    cpConstraint *joint_constr = cpPinJointNew( (cpBody *) a, (cpBody *) b, anchr1, anchr2 );
    return (value) joint_constr;
}


CAMLprim value
ml_cpSlideJointNew( value a, value b, value ml_anchr1, value ml_anchr2, value min, value max )
{
    cpVect anchr1;
    anchr1.x = Double_field(ml_anchr1,0);
    anchr1.y = Double_field(ml_anchr1,1);

    cpVect anchr2;
    anchr2.x = Double_field(ml_anchr2,0);
    anchr2.y = Double_field(ml_anchr2,1);

    cpConstraint *joint_constr = cpSlideJointNew( (cpBody *) a, (cpBody *) b, anchr1, anchr2, Double_val(min), Double_val(max) );
    return (value) joint_constr;
}

CAMLprim value
ml_cpSlideJointNew_bc(value * argv, int argn)
{
    return ml_cpSlideJointNew(
      argv[0], argv[1], argv[2], argv[3], argv[4], argv[5] );
}


CAMLprim value
ml_cpPivotJointNew( value a, value b, value ml_pivot )
{
    cpVect pivot;
    pivot.x = Double_field(ml_pivot,0);
    pivot.y = Double_field(ml_pivot,1);

    cpConstraint *joint_constr = cpPivotJointNew( (cpBody *) a, (cpBody *) b, pivot );
    return (value) joint_constr;
}


CAMLprim value
ml_cpGrooveJointNew( value a, value b, value ml_groove_a, value ml_groove_b, value ml_anchr2 )
{
    cpVect groove_a;
    groove_a.x = Double_field(ml_groove_a,0);
    groove_a.y = Double_field(ml_groove_a,1);

    cpVect groove_b;
    groove_b.x = Double_field(ml_groove_b,0);
    groove_b.y = Double_field(ml_groove_b,1);

    cpVect anchr2;
    anchr2.x = Double_field(ml_anchr2,0);
    anchr2.y = Double_field(ml_anchr2,1);

    cpConstraint *joint_constr = cpGrooveJointNew( (cpBody *) a, (cpBody *) b, groove_a, groove_b, anchr2 );
    return (value) joint_constr;
}


CAMLprim value
ml_cpConstraintFree( value constr )
{
    cpConstraintFree( (cpConstraint *) constr );
    return Val_unit;
}


CAMLprim value
ml_cpDampedSpringNew( value a, value b, value ml_anchr1, value ml_anchr2, value rest_length, value stiffness, value damping )
{
    cpVect anchr1;
    anchr1.x = Double_field(ml_anchr1,0);
    anchr1.y = Double_field(ml_anchr1,1);

    cpVect anchr2;
    anchr2.x = Double_field(ml_anchr2,0);
    anchr2.y = Double_field(ml_anchr2,1);

    cpConstraint *joint_constr = cpDampedSpringNew( (cpBody *) a, (cpBody *) b, anchr1, anchr2, Double_val(rest_length), Double_val(stiffness), Double_val(damping) );
    return (value) joint_constr;
}

CAMLprim value
ml_cpDampedSpringNew_bc(value * argv, int argn)
{
    return ml_cpDampedSpringNew(
      argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6] );
}


// Structure member access

CAMLprim value
ml_cpBodySetMass(value this, value val)
{
        ((cpBody *)this)->m = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetMassInverse(value this, value val)
{
        ((cpBody *)this)->m_inv = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetMoment(value this, value val)
{
        ((cpBody *)this)->i = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetMomentInverse(value this, value val)
{
        ((cpBody *)this)->i_inv = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetPos(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpBody *)this)->p = _val;
        return Val_unit;
}

CAMLprim value
ml_cpBodySetVel(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpBody *)this)->v = _val;
        return Val_unit;
}

CAMLprim value
ml_cpBodySetForce(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpBody *)this)->f = _val;
        return Val_unit;
}

CAMLprim value
ml_cpBodySetVelBias(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpBody *)this)->v_bias = _val;
        return Val_unit;
}

CAMLprim value
ml_cpBodySetAngle(value this, value val)
{
        ((cpBody *)this)->a = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetAVel(value this, value val)
{
        ((cpBody *)this)->w = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetTorque(value this, value val)
{
        ((cpBody *)this)->t = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetAVelBias(value this, value val)
{
        ((cpBody *)this)->w_bias = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetRot(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpBody *)this)->rot = _val;
        return Val_unit;
}

CAMLprim value
ml_cpBodySetData(value this, value val)
{
        ((cpBody *)this)->data = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetVelLim(value this, value val)
{
        ((cpBody *)this)->v_limit = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodySetAngVelLim(value this, value val)
{
        ((cpBody *)this)->w_limit = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSpaceSetIterations(value this, value val)
{
        ((cpSpace *)this)->iterations = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSpaceSetGravity(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSpace *)this)->gravity = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSpaceSetDamping(value this, value val)
{
        ((cpSpace *)this)->damping = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSpaceSetElasticIterations(value this, value val)
{
        ((cpSpace *)this)->elasticIterations = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetElasticity(value this, value val)
{
        ((cpShape *)this)->e = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetFriction(value this, value val)
{
        ((cpShape *)this)->u = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetSurfaceV(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpShape *)this)->surface_v = _val;
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetCollisionType(value this, value val)
{
        ((cpShape *)this)->collision_type = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetGroup(value this, value val)
{
        ((cpShape *)this)->group = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetLayers(value this, value val)
{
        ((cpShape *)this)->layers = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpShapeSetData(value this, value val)
{
        ((cpShape *)this)->data = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpCircleShapeSetCenter(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpCircleShape *)this)->c = _val;
        return Val_unit;
}

CAMLprim value
ml_cpCircleShapeSetRadius(value this, value val)
{
        ((cpCircleShape *)this)->r = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetA(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSegmentShape *)this)->a = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetB(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSegmentShape *)this)->b = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetNorm(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSegmentShape *)this)->n = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetThickness(value this, value val)
{
        ((cpSegmentShape *)this)->r = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetTA(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSegmentShape *)this)->ta = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetTB(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSegmentShape *)this)->tb = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSegmentShapeSetTNorm(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSegmentShape *)this)->tn = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetAnchor1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPinJoint *)this)->anchr1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetAnchor2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPinJoint *)this)->anchr2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetDist(value this, value val)
{
        ((cpPinJoint *)this)->dist = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetR1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPinJoint *)this)->r1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetR2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPinJoint *)this)->r2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetVect(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPinJoint *)this)->n = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetNMass(value this, value val)
{
        ((cpPinJoint *)this)->nMass = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetJNAcc(value this, value val)
{
        ((cpPinJoint *)this)->jnAcc = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetJNMax(value this, value val)
{
        ((cpPinJoint *)this)->jnMax = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpPinJointSetBias(value this, value val)
{
        ((cpPinJoint *)this)->bias = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetAnchor1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSlideJoint *)this)->anchr1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetAnchor2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSlideJoint *)this)->anchr2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetMin(value this, value val)
{
        ((cpSlideJoint *)this)->min = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetMax(value this, value val)
{
        ((cpSlideJoint *)this)->max = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetR1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSlideJoint *)this)->r1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetR2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSlideJoint *)this)->r2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetVect(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpSlideJoint *)this)->n = _val;
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetNMass(value this, value val)
{
        ((cpSlideJoint *)this)->nMass = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetJNAcc(value this, value val)
{
        ((cpSlideJoint *)this)->jnAcc = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetJNMax(value this, value val)
{
        ((cpSlideJoint *)this)->jnMax = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpSlideJointSetBias(value this, value val)
{
        ((cpSlideJoint *)this)->bias = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetAnchor1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->anchr1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetAnchor2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->anchr2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetR1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->r1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetR2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->r2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetK1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->k1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetK2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->k2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetJAcc(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->jAcc = _val;
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetJMaxLen(value this, value val)
{
        ((cpPivotJoint *)this)->jMaxLen = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpPivotJointSetBias(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpPivotJoint *)this)->bias = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetGrvN(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->grv_n = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetGrvA(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->grv_a = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetGrvB(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->grv_b = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetAnchor2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->anchr2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetGrvTn(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->grv_tn = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetClamp(value this, value val)
{
        ((cpGrooveJoint *)this)->clamp = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetR1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->r1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetR2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->r2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetK1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->k1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetK2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->k2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetJAcc(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->jAcc = _val;
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetJMaxLen(value this, value val)
{
        ((cpGrooveJoint *)this)->jMaxLen = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpGrooveJointSetBias(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpGrooveJoint *)this)->bias = _val;
        return Val_unit;
}

CAMLprim value
ml_cpContactSetP(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpContact *)this)->p = _val;
        return Val_unit;
}

CAMLprim value
ml_cpContactSetN(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpContact *)this)->n = _val;
        return Val_unit;
}

CAMLprim value
ml_cpContactSetDist(value this, value val)
{
        ((cpContact *)this)->dist = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetR1(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpContact *)this)->r1 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpContactSetR2(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpContact *)this)->r2 = _val;
        return Val_unit;
}

CAMLprim value
ml_cpContactSetNMass(value this, value val)
{
        ((cpContact *)this)->nMass = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetTMass(value this, value val)
{
        ((cpContact *)this)->tMass = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetBounce(value this, value val)
{
        ((cpContact *)this)->bounce = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetJNAcc(value this, value val)
{
        ((cpContact *)this)->jnAcc = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetJTAcc(value this, value val)
{
        ((cpContact *)this)->jtAcc = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetJBias(value this, value val)
{
        ((cpContact *)this)->jBias = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetBias(value this, value val)
{
        ((cpContact *)this)->bias = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpContactSetHash(value this, value val)
{
        ((cpContact *)this)->hash = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetNumContacts(value this, value val)
{
        ((cpArbiter *)this)->numContacts = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetE(value this, value val)
{
        ((cpArbiter *)this)->e = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetU(value this, value val)
{
        ((cpArbiter *)this)->u = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetSurface_vr(value this, value val)
{
        cpVect _val;
        _val.x = Double_field(val,0);
        _val.y = Double_field(val,1);

        ((cpArbiter *)this)->surface_vr = _val;
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetStamp(value this, value val)
{
        ((cpArbiter *)this)->stamp = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetSwappedColl(value this, value val)
{
        ((cpArbiter *)this)->swappedColl = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpArbiterSetState(value this, value val)
{
        ((cpArbiter *)this)->state = Int_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBBSetL(value this, value val)
{
        ((cpBB *)this)->l = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBBSetB(value this, value val)
{
        ((cpBB *)this)->b = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBBSetR(value this, value val)
{
        ((cpBB *)this)->r = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBBSetT(value this, value val)
{
        ((cpBB *)this)->t = Double_val(val);
        return Val_unit;
}

CAMLprim value
ml_cpBodyGetMass(value this)
{
        return caml_copy_double( ((cpBody *)this)->m );
}

CAMLprim value
ml_cpBodyGetMassInverse(value this)
{
        return caml_copy_double( ((cpBody *)this)->m_inv );
}

CAMLprim value
ml_cpBodyGetMoment(value this)
{
        return caml_copy_double( ((cpBody *)this)->i );
}

CAMLprim value
ml_cpBodyGetMomentInverse(value this)
{
        return caml_copy_double( ((cpBody *)this)->i_inv );
}

CAMLprim value
ml_cpBodyGetPos(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpBody *)this)->p ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpBodyGetVel(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpBody *)this)->v ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpBodyGetForce(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpBody *)this)->f ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpBodyGetVelBias(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpBody *)this)->v_bias ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpBodyGetAngle(value this)
{
        return caml_copy_double( ((cpBody *)this)->a );
}

CAMLprim value
ml_cpBodyGetAVel(value this)
{
        return caml_copy_double( ((cpBody *)this)->w );
}

CAMLprim value
ml_cpBodyGetTorque(value this)
{
        return caml_copy_double( ((cpBody *)this)->t );
}

CAMLprim value
ml_cpBodyGetAVelBias(value this)
{
        return caml_copy_double( ((cpBody *)this)->w_bias );
}

CAMLprim value
ml_cpBodyGetRot(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpBody *)this)->rot ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpBodyGetData(value this)
{
        return Val_int( ((cpBody *)this)->data );
}

CAMLprim value
ml_cpBodyGetVelLim(value this)
{
        return caml_copy_double( ((cpBody *)this)->v_limit );
}

CAMLprim value
ml_cpBodyGetAngVelLim(value this)
{
        return caml_copy_double( ((cpBody *)this)->w_limit );
}

CAMLprim value
ml_cpSpaceGetIterations(value this)
{
        return Val_int( ((cpSpace *)this)->iterations );
}

CAMLprim value
ml_cpSpaceGetGravity(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSpace *)this)->gravity ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSpaceGetDamping(value this)
{
        return caml_copy_double( ((cpSpace *)this)->damping );
}

CAMLprim value
ml_cpSpaceGetElasticIterations(value this)
{
        return Val_int( ((cpSpace *)this)->elasticIterations );
}

CAMLprim value
ml_cpSpaceGetStamp(value this)
{
        return Val_int( ((cpSpace *)this)->stamp );
}

CAMLprim value
ml_cpShapeGetElasticity(value this)
{
        return caml_copy_double( ((cpShape *)this)->e );
}

CAMLprim value
ml_cpShapeGetFriction(value this)
{
        return caml_copy_double( ((cpShape *)this)->u );
}

CAMLprim value
ml_cpShapeGetSurfaceV(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpShape *)this)->surface_v ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpShapeGetCollisionType(value this)
{
        return Val_int( ((cpShape *)this)->collision_type );
}

CAMLprim value
ml_cpShapeGetGroup(value this)
{
        return Val_int( ((cpShape *)this)->group );
}

CAMLprim value
ml_cpShapeGetLayers(value this)
{
        return Val_int( ((cpShape *)this)->layers );
}

CAMLprim value
ml_cpShapeGetData(value this)
{
        return Val_int( ((cpShape *)this)->data );
}

CAMLprim value
ml_cpShapeGetHashID(value this)
{
        return Val_cpHashValue( ((cpShape *)this)->hashid );
}

CAMLprim value
ml_cpCircleShapeGetCenter(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpCircleShape *)this)->c ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpCircleShapeGetRadius(value this)
{
        return caml_copy_double( ((cpCircleShape *)this)->r );
}

CAMLprim value
ml_cpSegmentShapeGetA(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSegmentShape *)this)->a ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSegmentShapeGetB(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSegmentShape *)this)->b ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSegmentShapeGetNorm(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSegmentShape *)this)->n ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSegmentShapeGetThickness(value this)
{
        return caml_copy_double( ((cpSegmentShape *)this)->r );
}

CAMLprim value
ml_cpSegmentShapeGetTA(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSegmentShape *)this)->ta ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSegmentShapeGetTB(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSegmentShape *)this)->tb ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSegmentShapeGetTNorm(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSegmentShape *)this)->tn ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPolyShapeGetNumVerts(value this)
{
        return Val_int( ((cpPolyShape *)this)->numVerts );
}

CAMLprim value
ml_cpPolyShapeGetVects(value this)
{
        CAMLparam0();
        CAMLlocal2( ml_ret, vert_i );

        int num = ((cpPolyShape *)this)->numVerts;
        cpVect *verts =  ((cpPolyShape *)this)->verts ;

        ml_ret = caml_alloc(num, 0);

        for (int i=0; i<num; i++) {

                vert_i = caml_alloc(2 * Double_wosize, Double_array_tag);

                Store_double_field( vert_i, 0, verts[i].x );
                Store_double_field( vert_i, 1, verts[i].y );

                Store_field( ml_ret, i, vert_i );
        }

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPolyShapeGetTVerts(value this)
{
        CAMLparam0();
        CAMLlocal2( ml_ret, vert_i );

        int num = ((cpPolyShape *)this)->numVerts;
        cpVect *verts =  ((cpPolyShape *)this)->tVerts ;

        ml_ret = caml_alloc(num, 0);

        for (int i=0; i<num; i++) {

                vert_i = caml_alloc(2 * Double_wosize, Double_array_tag);

                Store_double_field( vert_i, 0, verts[i].x );
                Store_double_field( vert_i, 1, verts[i].y );

                Store_field( ml_ret, i, vert_i );
        }

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPinJointGetAnchor1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPinJoint *)this)->anchr1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPinJointGetAnchor2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPinJoint *)this)->anchr2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPinJointGetDist(value this)
{
        return caml_copy_double( ((cpPinJoint *)this)->dist );
}

CAMLprim value
ml_cpPinJointGetR1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPinJoint *)this)->r1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPinJointGetR2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPinJoint *)this)->r2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPinJointGetVect(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPinJoint *)this)->n ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPinJointGetNMass(value this)
{
        return caml_copy_double( ((cpPinJoint *)this)->nMass );
}

CAMLprim value
ml_cpPinJointGetJNAcc(value this)
{
        return caml_copy_double( ((cpPinJoint *)this)->jnAcc );
}

CAMLprim value
ml_cpPinJointGetJNMax(value this)
{
        return caml_copy_double( ((cpPinJoint *)this)->jnMax );
}

CAMLprim value
ml_cpPinJointGetBias(value this)
{
        return caml_copy_double( ((cpPinJoint *)this)->bias );
}

CAMLprim value
ml_cpSlideJointGetAnchor1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSlideJoint *)this)->anchr1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSlideJointGetAnchor2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSlideJoint *)this)->anchr2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSlideJointGetMin(value this)
{
        return caml_copy_double( ((cpSlideJoint *)this)->min );
}

CAMLprim value
ml_cpSlideJointGetMax(value this)
{
        return caml_copy_double( ((cpSlideJoint *)this)->max );
}

CAMLprim value
ml_cpSlideJointGetR1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSlideJoint *)this)->r1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSlideJointGetR2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSlideJoint *)this)->r2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSlideJointGetVect(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpSlideJoint *)this)->n ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpSlideJointGetNMass(value this)
{
        return caml_copy_double( ((cpSlideJoint *)this)->nMass );
}

CAMLprim value
ml_cpSlideJointGetJNAcc(value this)
{
        return caml_copy_double( ((cpSlideJoint *)this)->jnAcc );
}

CAMLprim value
ml_cpSlideJointGetJNMax(value this)
{
        return caml_copy_double( ((cpSlideJoint *)this)->jnMax );
}

CAMLprim value
ml_cpSlideJointGetBias(value this)
{
        return caml_copy_double( ((cpSlideJoint *)this)->bias );
}

CAMLprim value
ml_cpPivotJointGetAnchor1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->anchr1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetAnchor2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->anchr2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetR1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->r1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetR2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->r2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetK1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->k1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetK2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->k2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetJAcc(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->jAcc ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpPivotJointGetJMaxLen(value this)
{
        return caml_copy_double( ((cpPivotJoint *)this)->jMaxLen );
}

CAMLprim value
ml_cpPivotJointGetBias(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpPivotJoint *)this)->bias ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetGrvN(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->grv_n ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetGrvA(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->grv_a ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetGrvB(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->grv_b ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetAnchor2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->anchr2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetGrvTn(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->grv_tn ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetClamp(value this)
{
        return caml_copy_double( ((cpGrooveJoint *)this)->clamp );
}

CAMLprim value
ml_cpGrooveJointGetR1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->r1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetR2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->r2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetK1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->k1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetK2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->k2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetJAcc(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->jAcc ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpGrooveJointGetJMaxLen(value this)
{
        return caml_copy_double( ((cpGrooveJoint *)this)->jMaxLen );
}

CAMLprim value
ml_cpGrooveJointGetBias(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpGrooveJoint *)this)->bias ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpContactGetP(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpContact *)this)->p ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpContactGetN(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpContact *)this)->n ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpContactGetDist(value this)
{
        return caml_copy_double( ((cpContact *)this)->dist );
}

CAMLprim value
ml_cpContactGetR1(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpContact *)this)->r1 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpContactGetR2(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpContact *)this)->r2 ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpContactGetNMass(value this)
{
        return caml_copy_double( ((cpContact *)this)->nMass );
}

CAMLprim value
ml_cpContactGetTMass(value this)
{
        return caml_copy_double( ((cpContact *)this)->tMass );
}

CAMLprim value
ml_cpContactGetBounce(value this)
{
        return caml_copy_double( ((cpContact *)this)->bounce );
}

CAMLprim value
ml_cpContactGetJNAcc(value this)
{
        return caml_copy_double( ((cpContact *)this)->jnAcc );
}

CAMLprim value
ml_cpContactGetJTAcc(value this)
{
        return caml_copy_double( ((cpContact *)this)->jtAcc );
}

CAMLprim value
ml_cpContactGetJBias(value this)
{
        return caml_copy_double( ((cpContact *)this)->jBias );
}

CAMLprim value
ml_cpContactGetBias(value this)
{
        return caml_copy_double( ((cpContact *)this)->bias );
}

CAMLprim value
ml_cpContactGetHash(value this)
{
        return Val_int( ((cpContact *)this)->hash );
}

CAMLprim value
ml_cpArbiterGetNumContacts(value this)
{
        return Val_int( ((cpArbiter *)this)->numContacts );
}

CAMLprim value
ml_cpArbiterGetPA(value this)
{
        return (value)  ((cpArbiter *)this)->a ;
}

CAMLprim value
ml_cpArbiterGetPB(value this)
{
        return (value)  ((cpArbiter *)this)->b ;
}

CAMLprim value
ml_cpArbiterGetE(value this)
{
        return caml_copy_double( ((cpArbiter *)this)->e );
}

CAMLprim value
ml_cpArbiterGetU(value this)
{
        return caml_copy_double( ((cpArbiter *)this)->u );
}

CAMLprim value
ml_cpArbiterGetSurface_vr(value this)
{
        CAMLparam0();
        CAMLlocal1( ml_ret );

        cpVect _ret =  ((cpArbiter *)this)->surface_vr ;
        
        ml_ret = caml_alloc(2 * Double_wosize, Double_array_tag);
        Store_double_field( ml_ret, 0, _ret.x );
        Store_double_field( ml_ret, 1, _ret.y );

        CAMLreturn( ml_ret );
}

CAMLprim value
ml_cpArbiterGetStamp(value this)
{
        return Val_int( ((cpArbiter *)this)->stamp );
}

CAMLprim value
ml_cpArbiterGetSwappedColl(value this)
{
        return Val_int( ((cpArbiter *)this)->swappedColl );
}

CAMLprim value
ml_cpArbiterGetState(value this)
{
        return Val_int( ((cpArbiter *)this)->state );
}

CAMLprim value
ml_cpBBGetL(value this)
{
        return caml_copy_double( ((cpBB *)this)->l );
}

CAMLprim value
ml_cpBBGetB(value this)
{
        return caml_copy_double( ((cpBB *)this)->b );
}

CAMLprim value
ml_cpBBGetR(value this)
{
        return caml_copy_double( ((cpBB *)this)->r );
}

CAMLprim value
ml_cpBBGetT(value this)
{
        return caml_copy_double( ((cpBB *)this)->t );
}
